#pragma once

#include "cocos2d.h"

#define THEME_R 255
#define THEME_G 255
#define THEME_B 255
#define THEMECOLORBA(a) pUI->themeColorB(a)
#define THEMECOLORFA(a) pUI->themeColorF(a)
#define THEMECOLORB pUI->themeColorB()
#define THEMECOLORF pUI->themeColorF()
#define THEMECOLOR3B pUI->themeColor3B()

#define TEXT_R 64
#define TEXT_G 64
#define TEXT_B 64
#define TEXTCOLORBA(a) pUI->textColorB(a)
#define TEXTCOLORFA(a) pUI->textColorF(a)
#define TEXTCOLORB pUI->textColorB()
#define TEXTCOLORF pUI->textColorF()
#define TEXTCOLOR3B pUI->textColor3B()

#define UICOMBGF  pUI->uicombgColorF()
#define UICOMBGB  pUI->uicombgColorB()
#define UICOMBG3B pUI->uicombgColor3B()
#define UICOMFGF  pUI->uicomfgColorF()
#define UICOMFGB  pUI->uicomfgColorB()
#define UICOMFG3B pUI->uicomfgColor3B()

#define ANCH_TL Vec2::ANCHOR_TOP_LEFT
#define ANCH_TR Vec2::ANCHOR_TOP_RIGHT
#define ANCH_BL Vec2::ANCHOR_BOTTOM_LEFT
#define ANCH_BR Vec2::ANCHOR_BOTTOM_RIGHT
#define ANCH_M  Vec2::ANCHOR_MIDDLE
#define ANCH_MT Vec2::ANCHOR_MIDDLE_TOP
#define ANCH_MB Vec2::ANCHOR_MIDDLE_BOTTOM
#define ANCH_ML Vec2::ANCHOR_MIDDLE_LEFT
#define ANCH_MR Vec2::ANCHOR_MIDDLE_RIGHT

#define FONTA "fonts/TTZhiHeiJ-W4.ttf"
#define FONTB "fonts/msyh.ttc"

USING_NS_CC;
using namespace std;

class UI
{
	public:
	UI(Size s);

	int theme_r = THEME_R;
	int theme_g = THEME_G;
	int theme_b = THEME_B;

	int text_r = TEXT_R;
	int text_g = TEXT_G;
	int text_b = TEXT_B;

	int uicom_bg_r = 255;
	int uicom_bg_g = 255;
	int uicom_bg_b = 255;
	int uicom_bg_a = 255;

	int uicom_fg_r = 64;
	int uicom_fg_g = 64;
	int uicom_fg_b = 64;
	int uicom_fg_a = 255;

	Color4F themeColorF(GLubyte alpha = 255);
	Color4B themeColorB(GLubyte alpha = 255);
	Color3B themeColor3B();
	Color4F textColorF(GLubyte alpha = 255);
	Color4B textColorB(GLubyte alpha = 255);
	Color3B textColor3B();
	Color4F uicombgColorF();
	Color4B uicombgColorB();
	Color3B uicombgColor3B();
	Color4F uicomfgColorF();
	Color4B uicomfgColorB();
	Color3B uicomfgColor3B();

	float dsnSize(float p1920);
	static void setWndSize(float width);
	static void setWndTItle(const wchar_t* title);
	static Size getNodeScaledSize(Node* node);
	static void setNodeFillInArea(Node* node, Size fillarea);
	static void setNodeFitInArea(Node* node, Size fillarea);
	static void setNodeAnch(Node* node, Vec2 anch);

	//angelZ must be 90 or -90
	static Vec2 convertOrbitPos(Vec2 worldPos, float areaPosX, float areaWidth, int angelZ);

	static string fonta() { return FONTA; }
	static string fontb() { return FONTB; }

	static void setEventFlagByBit(unsigned short flagbitpos);
	static void setEventFlag(unsigned int flag);
	static unsigned int moveEventFlagUp();
	static unsigned int moveEventFlagDown();
	static unsigned int getEventFlag();

	private:
	Size visibleSize;
	unsigned int eventFlag = 0x0001;

	void _setEventFlagByBit(unsigned short flagbitpos);
	unsigned int _getEventFlag();
};
